<template>
<div>
  <!--<vue-markdown>{{content}}</vue-markdown>-->
    <Row>
        <input v-model="content" placeholder="请输入标题" ></input>
        <Button type="primary" @click="getLogs">查询</Button>
    </Row>
  <div class="content">
    <template v-for="log in logs">
      <span class="log-str">
        [{{getTime(log)}}] [{{log.content}}] 详细信息:{{log.detail}}, 组id:{{log.gid.toNumber()}}, 模块: {{log.module}}, 操作者: {{log.operator}} <br>
      </span>
    </template>
  </div>
  <Page class="bottom-page" :total="totalPage" :current="crtPage" :page-size="pageSize" show-total show-elevator @on-change="onChange"></Page>
</div>
</template>

<script>
// import VueMarkdown from 'vue-markdown'
import {getLog} from '@/api/log.js'
import { getVO } from '@/common/proto-vo.js'
// import {parseTime} from '@/common/dateutil.js'
export default {
  data () {
    return {
      content: '',
      logs: [],
      crtPage: 1,
      totalPage: 0,
      pageSize: 22
    }
  },
  created () {
    this.getLogs()
  },
  methods: {
    getTime (log) {
      let str = '' + log.createTime.toNumber()
      return str.substr(0, 4) + '-' + str.substr(4, 2) + '-' + str.substr(6, 2) +
        ' ' + str.substr(8, 2) + ':' + str.substr(10, 2) + ':' + str.substr(12, 2)
      // return parseTime(parseInt( / 1000))
    },
    getLogs () {
      getLog(this.content, this.crtPage, this.pageSize).then((data) => {
        if (!data) {
          return
        }
        let AdminLogVO = getVO('AdminLogVO')
        let pv = data.data.data
        let len = pv.data.length
        let vos = []
        for (let i = 0; i < len; i++) {
          let vo = AdminLogVO.decode(pv.data[i])
          vos.push(vo)
        }
        this.logs = vos
        this.totalPage = pv.intValues[1]
      })
    },
    onChange (item) {
      console.log(item)
      this.crtPage = item
      this.getLogs()
    }
  }
}
</script>

<style scoped>
.log-str{
  font-size: 14px;
  margin-bottom: 2px;
}
.content{
  min-height: 460px;
}
.bottom-page{
  margin-top: 5px;
  margin-bottom: 10px;
  float: right;
}
</style>
